import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class Demo1 {
    public static void main(String[] args)  {
        /*try {
            //没有传true默认打开先清除文件内的内容再进行写入
            OutputStream stream = new FileOutputStream("d:/code/J2025/J20250915-IO/test.txt",true);
            stream.write(86);
            stream.write(87);
            stream.write(88);
            stream.write(88);
            stream.write(88);
            stream.write(88);
            stream.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }*/

        try (OutputStream outputStream = new FileOutputStream("d:/code/J2025/J20250915-IO/test.txt")){
            //try with resources 自动管理文件的关闭 不用手动close释放
            byte[] bytes = {86,97,78,89,89};
            outputStream.write(bytes);

        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
